package com.yuantu.judiciary.controller;

import com.alibaba.fastjson2.JSONObject;
import com.yuantu.judiciary.common.Response;
import com.yuantu.judiciary.common.ResponseFactory;
import com.yuantu.judiciary.dao.*;
import com.yuantu.judiciary.model.domain.AccountDO;
import com.yuantu.judiciary.model.domain.QueryRecordDO;
import com.yuantu.judiciary.model.vo.CheckPersonReportVO;
import com.yuantu.judiciary.service.IApiAliAuthService;
import com.yuantu.judiciary.service.IApiAliOpenService;
import com.yuantu.judiciary.service.ICheckPersonService;
import com.yuantu.judiciary.service.ISmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 阿里外部接口
 *
 * @author syw
 * @since 2023-07-08
 **/
@RestController
@RequestMapping(value = "/open/ali")
@Api(tags = "阿里外部接口")
@RequiredArgsConstructor
public class ApiAliController {

    private final IApiAliAuthService authService;


    @ApiOperation(value = "获取加密参数")
    @GetMapping("/get/encryption-param")
    public Response<String> getEncryptionParam(@RequestParam String sign) {
        return ResponseFactory.okResponse(authService.getEncryptionParam(sign));
    }

    @ApiOperation(value = "获取身份验证地址")
    @GetMapping("/get/verify-url")
    public Response<String> getVerifyUrl(@RequestParam String sign) {
        return ResponseFactory.okResponse(authService.getVerifyUrl(sign));
    }

    @ApiOperation(value = "获取身份验证结果")
    @GetMapping("/get/verify-result")
    public Response<Boolean> getVerifyResult(@RequestParam String sign) {
        return ResponseFactory.okResponse(authService.getVerifyResult(sign));
    }

    @ApiOperation(value = "获取查自己个人报告信息")
    @GetMapping("/get/personal-report")
    public Response<CheckPersonReportVO> getPersonalReport(@RequestParam String sign) {
        return ResponseFactory.okResponse(authService.getPersonalReport(sign));
    }

//    @ApiOperation(value = "测试")
//    @GetMapping("/get/personal-test")
//    public Response<String> test() {
//        Long queryId = 846L;
//        QueryRecordDO query = queryRecordDao.findByIdAndDeletedFalse(queryId);
//        AccountDO accountDO = accountDao.findByIdAndDeletedFalse(query.getCreatorId());
//        String phone = userInfoDao.findByIdAndDeletedFalse(accountDO.getUserId()).getPhone();
//        String cxr = accountDO.getUsername();
//        String bcxr = JSONObject.parseObject(query.getContent()).getString("name");
//        smsService.sendAuthSuccess(phone,cxr,bcxr);
//        return ResponseFactory.okResponse("ok");
//    }



}
